//
//  HD_HSP_Boutique_ViewController.m
//  HDLiaoNingMeseum
//
//  Created by HDHaoShaoPeng on 2017/8/9.
//  Copyright © 2017年 HDNiuKuiming. All rights reserved.
//

#import "HD_HSP_Boutique_ViewController.h"
#import "HD_HSP_Exhibit_Model.h"
#import "HD_HSP_Web_ViewController.h"
#import "MBProgressHUD.h"
#import "HDResourceCollectionView.h"
#import "HD_HSP_MainWeb_ViewController.h"

static HDDeclare *declare;

@interface HD_HSP_Boutique_ViewController ()
@property (strong, nonatomic) UIImageView *myIndicatorImageView;
@property (nonatomic) BOOL autoing;
@property (assign, nonatomic) BOOL playFlag;
@property (strong, nonatomic) HD_HSP_Exhibit_Model *detailItem;
@property (strong, nonatomic) NSArray *myDataArray;
@property (strong, nonatomic) IBOutlet HDResourceCollectionView *myCollectionView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;



@property (assign, nonatomic) NSInteger myIndex;
@end

@implementation HD_HSP_Boutique_ViewController

- (void)awakeFromNib
{
    
    declare = [HDDeclare sharedDeclare];
    _autoing = YES;
    
    [super awakeFromNib];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    declare = [HDDeclare sharedDeclare];
    self.myDataArray = [declare giveMeBoutiqueData];
    self.titleLabel.text = declare.museumRelics;
    self.titleLabel.font = [UIFont fontWithName:@"FZQKBYSJW--GB1-0" size:18.0];
    
    self.detailItem = nil;
    _myIndex = 0;
    _myCollectionView.dataArray = self.myDataArray;
    
    __weak HD_HSP_Boutique_ViewController *VC = self;
    _myCollectionView.myTapBlock = ^(NSInteger myInteger){
        [VC exhibitClickedWith:myInteger];
    };
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.myCollectionView reloadData];
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.detailItem = nil;
}

-(void)exhibitClickedWith:(NSInteger)row
{
    HD_HSP_Exhibit_Model *model = self.myDataArray[row];
    HD_HSP_MainWeb_ViewController *firVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"HD_HSP_MainWeb_ViewController"];
    firVC.model = model;
    [self.navigationController pushViewController:firVC animated:YES];
}



- (IBAction)backClicked:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark - ------- FetchData Methods --------


- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//    NSString *mp3Path = [NSString stringWithFormat:@"%@/%@.html", self.detailItem.identify, self.detailItem.identify];
//    NSString *resourcePath = [NSString stringWithFormat:@"%@/Resource/%@_B/%@",[declare applicationLibraryDirectory], [declare.language uppercaseString], mp3Path];
//    if ([[NSFileManager defaultManager]fileExistsAtPath:resourcePath])
//    {
//    }
//    else
//    {
//    }
}


#pragma mark - ------- Dealloc Methods --------

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}


-(void)dealloc
{
    [self.myIndicatorImageView removeFromSuperview];
    self.myIndicatorImageView = nil;
    
    self.detailItem = nil;
}

@end
